package cn.dglydrpy.eshop.website;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@SpringBootApplication(exclude = { FreeMarkerAutoConfiguration.class }, scanBasePackages = {"cn.dglydrpy.eshop"} )
//使用注解方式整合mybatis
@MapperScan(basePackages = "cn.dglydrpy.eshop.dal.mapper")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);//args参数用于命令行启动,如果不加args参数,用命令行启动时参数无效
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("     Let's inspect the beans provided by Spring Boot!     ");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : args) {
                System.out.println(beanName);
            }
        };
    }
}

